home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / SENTENCE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  450 b   |  30 lines

  1. /* sentence.c - count sentences */
  2. #include "stdio.h"
  3.  
  4. int ns ;
  5.  
  6. main()
  7.  {
  8.    int c ;
  9.    ns = 0 ;
  10.         /* get each charcter and check it */
  11.    c = getchar() ;
  12.    while( c != EOF )
  13.      { check_end(c) ;
  14.        c = getchar() ;
  15.      }
  16.  
  17.    printf(" %d sentences",ns) ;
  18.  }
  19.  
  20. int check_end(ch)    /* check for end-of sentence char. */
  21.  int ch ;
  22.  {
  23.     if(    (ch == '.')
  24.        ||  (ch == '?')
  25.        ||  (ch == '!') )
  26.        ns = ns + 1 ;
  27.  }
  28.  
  29.  
  30.